home *** CD-ROM | disk | FTP | other *** search
- /*
- File: SampleStorageDriver.h
-
- Contains: All definitions used by the Sample Storage Driver
-
- Version: 1.1
-
- Copyright: © 1998-1999 by Apple Computer, Inc., all rights reserved.
-
- */
-
-
- #ifndef __SAMPLESTORAGEDRIVER__
- #define __SAMPLESTORAGEDRIVER__
-
- #include <USB.h>
- #include "SampleStorageDriverAPI.h"
-
-
- #if DEBUG
- #define IF_DEBUG(x) x
- #else
- #define IF_DEBUG(x)
- #endif
-
- #define kStrStorageClass "\pStorageClass: "
-
- #define kStorageRetryCount 5
- #define kMaxTransitions 1
- #define kIntDataSize 8
- #define kStatusSize 2 // USB Status
- #define kUSBMaxBulkTransfer 0x200000 // Max transfer is 2MB
-
- // These states are used by StorageDeviceInitiateConfiguration
- enum driverConfigStates
- {
- kUndefined = 0,
-
- kSetConfig,
- kGetFullConfiguration,
- kFindStorageInterface,
- kStorageConfigureInterface,
-
- kNewInterfaceRef,
- kStorageFindInterruptPipe,
- kStorageFindBulkInPipe,
- kStorageFindBulkOutPipe,
- kStorageReadInterrupt,
-
- kStorageExecuteCommand, // Begin execution of user command
- kStorageExecuteCommandCompletion, // Complete the user command
- kStorageBulkIOComplete, // Complete the bulk read
- kStorageGetStatus, // Complete the GetStatus request
- kStorageGetStatusBulkRead, // Get the status data
-
- kNilCompletion,
-
- kReturnFromDriver = 0x1000,
- kRetryTransaction = 0x2000,
- kAsyncTransaction = 0x4000,
- kCompletionPending = 0x8000
- };
-
- // Structure for the global PB's
- struct StorageClassTransactionPB {
- USBPB usbPB;
- UInt8 cdb[kCDBSize];
- UInt32 currentState;
- Boolean busy;
- UInt32 flags; // Flags from StorageClassRequest pb
- StorageExecuteCommandPBPtr userPBPtr;
- };
- typedef struct StorageClassTransactionPB StorageClassTransactionPB;
- typedef StorageClassTransactionPB *StorageClassTransactionPBPtr;
-
-
- struct StorageClassInfo {
- USBPB usbPB; // Configuration block
-
- // Device info
- UInt8 firmwareVersion[2];
-
- // Interrupt pipe
- USBPipeRef interruptPipeRef; // USB pipe reference
- UInt8 interruptReport[kIntDataSize];
-
- // mandatory bulk in pipe
- USBPipeRef readPipeRef; // USB pipe reference
-
- // mandatory bulk out pipe
- USBPipeRef writePipeRef; // USB pipe reference
-
- // device: configuration and interface details
- USBDeviceRef interfaceRef; // USB device reference
- USBDeviceRef deviceRef; // USB device reference
- USBConfigurationDescriptorPtr pFullConfigDescriptor;
- USBConfigurationDescriptor partialConfigDescriptor;
-
- USBInterfaceDescriptor interfaceDescriptors[32];
- USBInterfaceRef interfaceRefArray[32];
- USBRqIndex interfaceCount;
- USBRqIndex interfaceIndex;
-
- UInt32 interfaceNumber;
-
- USBDeviceDescriptor deviceDescriptor; // copy for local reference
- USBInterfaceDescriptorPtr pInterfaceDescriptor; // copy for local reference
-
- // class driver async transactions
- SInt32 transDepth; // don't nest transactions
- SInt32 retryCount; // automatically retry transactions
- UInt32 currentState; // State machine state
- };
- typedef struct StorageClassInfo StorageClassInfo;
- typedef StorageClassInfo *StorageClassInfoPtr;
-
-
- struct StorageClassStatusPB {
- USBPB usbPB;
- Boolean busy;
- StorageStatusPBPtr userPBPtr;
- UInt8 status[kStatusSize];
- };
- typedef struct StorageClassStatusPB StorageClassStatusPB;
- typedef StorageClassStatusPB *StorageClassStatusPBPtr;
-
-
- struct StorageClassControlPB {
- USBPB usbPB;
- Boolean busy;
- StorageControlPBPtr userPBPtr;
- };
- typedef struct StorageClassControlPB StorageClassControlPB;
- typedef StorageClassControlPB *StorageClassControlPBPtr;
-
-
- // Function protoypes
- extern OSStatus StorageClassDriverInitialize(void);
-
- extern OSStatus StorageClassDriverControl(UInt32 theControlSelector, void *theControlData);
-
- extern OSStatus StorageClassDriverStatus(UInt32 theInfoSelector, void *theInfo);
-
- extern OSStatus StorageClassDriverExecuteCommand(StorageExecuteCommandPBPtr storageExecuteCommandPBPtr);
-
-
- #endif /* __SAMPLESTORAGEDRIVER__ */